package com.hmall.common.clients;

import com.hmall.common.dto.PageDTO;
import com.hmall.common.pojo.Item;
import org.apache.ibatis.annotations.Delete;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

@FeignClient("itemservice")
public interface ItemClient {
    /**
     * 查询全部商品
     * @param pageNumber
     * @param pageSize
     * @return
     */
    @GetMapping("/item/list")
    PageDTO getAll(@RequestParam("page") Integer pageNumber,
                          @RequestParam("size")Integer pageSize);

    /**
     * 根据id查询商品
     * @param id
     * @return
     */
    @GetMapping("/item/{id}")
    Item getById(@PathVariable Long id);

    /**
     * 根据id删除商品
     * @param id
     */
    @DeleteMapping("item/{id}")
    void deleteById(@PathVariable Long id);

    /**
     * 扣减库存
     * @param itemId
     * @param type
     * @param num
     */
    @PutMapping("/item/stock/{type}/{itemId}/{num}")
    void updateStockById(@PathVariable("itemId") Long itemId,  @PathVariable("type") String type, @PathVariable("num") Integer num);
}
